package com.zy.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zy.entity.User;
import com.zy.entity.ZyUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
@Mapper
public interface UserMapper extends BaseMapper<User> {

    @Select("SELECT id,`name`,phone,email,post,birthday,path,letter FROM `user` u,(SELECT fid FROM friends WHERE uid=#{uid}) f WHERE u.id=f.fid")
    public List<User> userList(Integer uid);


    @Select("SELECT department_name,department_id FROM department d,(SELECT department_id did FROM post_department_mapping m,(SELECT post_id FROM post p, (SELECT post FROM `user` WHERE id=#{uid}) u WHERE p.post_name=u.post) po  WHERE m.post_id=po.post_id) de WHERE d.department_id=de.did")
    public Map<String,String> getDepartmentName(Integer uid);

}
